<template>
	<view class="customer-record full box relative flex-col bg-primary">
		<view class="header-wrap">
			<view class="search-wrap">
				<u-icon name="search" size="30rpx" color="#8D8D8D"></u-icon>
				<input v-model="queryKey" class="search-input" placeholder="请输入姓名或手机号码" />
			</view>
			<view class="data-wrap">
				<text class="date-value">2025-03</text>
				<u-icon name="close-circle-fill" color="#8D8D8D" size="26rpx" />
			</view>
			<view class="search-btn">
				<text>搜索</text>
			</view>
		</view>
		<view class="w-wrap">
			<view class="w-inner">
				<mescroll-uni @init="mescrollInit" :fixed="false" @down="downCallback" @up="upCallback">
					<view class="record-list">
						<view class="record-item">
							<view class="item-name">
								<text>档案号：</text>
							</view>
							<!-- <view class="desc-wrap">
								<text class="desc-item">创建时间：</text>
							</view> -->
							<view class="date-item">
								<text>创建时间：2023-12-26</text>
							</view>
							<view class="date-item">
								<text>联系人：</text>
							</view>
							<view class="date-item">
								<text>所在地区：</text>
							</view>
							<view class="item-countder">
								<view class="count-date">
									<text>2025年03月</text>
								</view>
								<view class="count-line">
									<view class="count-item">
										<text class="item-label">发展水管家</text>
										<text class="item-value">0</text>
									</view>
									<view class="count-item">
										<text class="item-label">客户裂变量</text>
										<text class="item-value">0</text>
									</view>
								</view>
								<view class="count-line active">
									<view class="count-item">
										<text class="item-label">首充金额</text>
										<text class="item-value">¥0.00</text>
									</view>
									<view class="count-item">
										<text class="item-label">续充金额</text>
										<text class="item-value">¥0.00</text>
									</view>
								</view>
							</view>
						</view>
					</view>
				</mescroll-uni>
			</view>
		</view>
	</view>
</template>

<script>
	import { request } from "@/utils/tool.js";
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	export default {
		mixins: [MescrollMixin],
		data() {
			return {
				queryKey: "",
				date: "",
				list: []
			}
		},
		methods: {
			async upCallback(ev) {
				const { num, size } = ev
				const { queryKey, date } = this
				const resp = await request({
					url: "/kehudangan/lists",
					data: {
						page_no: num,
						page_size: size,
						keyword: queryKey,
						date
					},
					method: "GET",
				})
				const { lists, count } = resp.data
				if (num === 1) this.list = []
				this.list.push(...lists)
				console.log(lists, 'lisats');
				this.mescroll.endBySize(lists.length, count)
			}
		},
	}
</script>

<style lang="scss" scoped>
	.customer-record {
		.record-list {
			padding: 24rpx 18rpx 0;
			box-sizing: border-box;
			position: relative;

			.record-item {
				padding: 20rpx 34rpx;
				background: #FFFFFF;
				border-radius: 16rpx 16rpx 16rpx 16rpx;
				margin-bottom: 24rpx;

				&:last-child {
					margin-bottom: 0;
				}

				.item-countder {
					margin-top: 10rpx;
					padding: 12rpx 28rpx 28rpx;
					background: #F5F3F3;
					border-radius: 16rpx 16rpx 16rpx 16rpx;


					.count-line {
						display: flex;
						flex-flow: row nowrap;
						align-items: center;

						&:last-child {
							margin-top: 24rpx;
						}

						&.active {
							.count-item {
								--first-circle-color: #2AB7AC;

								&:last-child {
									--first-circle-color: #45AE56;
								}

								.item-value {
									color: #D26B40;
								}
							}
						}

						.count-item {
							flex: 1;
							display: flex;
							flex-flow: column;
							align-items: center;
							--first-circle-color: #623BA9;

							&:last-child {
								--first-circle-color: #D84D46;
							}

							.item-label {
								font-size: 24rpx;
								color: #77797A;
								line-height: 44rpx;
								position: relative;


								&::before {
									content: "";
									display: block;
									position: absolute;
									width: 12rpx;
									height: 12rpx;
									background: var(--first-circle-color);
									border-radius: 50%;
									left: -20rpx;
									top: 50%;
									transform: translateY(-50%);
								}
							}

							.item-value {
								font-weight: bold;
								font-size: 32rpx;
								color: #2F3132;
								margin-top: 12rpx;
							}
						}
					}

					.count-date {
						font-weight: bold;
						font-size: 26rpx;
						color: #000000;
						line-height: 44rpx;
						margin-bottom: 10rpx;
					}
				}

				.date-item {
					font-size: 28rpx;
					color: #515151;
					line-height: 44rpx;
				}

				.desc-wrap {
					font-size: 28rpx;
					color: #515151;
					line-height: 44rpx;

					.desc-item:first-child {
						padding-right: 114rpx;
					}
				}

				.item-name {
					font-size: 28rpx;
					color: #515151;
					line-height: 44rpx;
				}
			}
		}

		.header-wrap {
			padding: 10rpx;
			box-sizing: border-box;
			position: relative;
			display: flex;
			align-items: center;
			background-color: #fff;

			.search-btn {
				width: 116rpx;
				height: 64rpx;
				background: #3361F0;
				border-radius: 32rpx 32rpx 32rpx 32rpx;
				margin-left: auto;
				line-height: 64rpx;
				font-size: 26rpx;
				color: #FFFFFF;
				text-align: center;
			}

			.data-wrap {
				margin-left: 18rpx;
				padding: 8rpx 20rpx 8rpx 20rpx;
				display: flex;
				align-items: center;
				background: #F4F4F4;
				border-radius: 30rpx 30rpx 30rpx 30rpx;

				.date-value {
					font-size: 26rpx;
					color: #8D8D8D;
					line-height: 44rpx;
					margin-right: 10rpx;
				}
			}

			.search-wrap {
				display: flex;
				align-items: center;
				padding: 8rpx 18rpx;
				box-sizing: border-box;
				position: relative;
				background: #F4F4F4;
				border-radius: 30rpx 30rpx 30rpx 30rpx;

				.search-input {
					margin-left: 8rpx;
					height: 44rpx;
					font-size: 26rpx;
					color: #333;
					line-height: 44rpx;
					flex: 1;
				}
			}
		}
	}
</style>